package it.polimi.protopeer.simulation;

import java.net.InetAddress;
import java.net.UnknownHostException;

import protopeer.*;
import protopeer.measurement.*;
import protopeer.network.*;
import protopeer.network.delayloss.*;
import protopeer.network.mina.MinaAddress;
import protopeer.servers.bootstrap.*;
import protopeer.util.quantities.*;

public class CommandFlooderExperiment extends LiveExperiment {
	public static void main(String[] args) {
		Experiment.initEnvironment();
		// take the peer index from the first command-line argument
//		MainConfiguration.getSingleton().peerIndex = Integer.parseInt(args[0]);
//		// take the port number to bind to from the second command-line argument
//		MainConfiguration.getSingleton().peerPort = Integer.parseInt(args[1]);
		MainConfiguration.getSingleton().peerIndex = 0;
		// take the port number to bind to from the second command-line argument
		MainConfiguration.getSingleton().peerPort = 22;
		System.out.println("Hi, I'm peer with the index "
				+ MainConfiguration.getSingleton().peerIndex);

		CommandFlooderExperiment experiment = new CommandFlooderExperiment();
		experiment.init();
		String[] d={"192.168.1.1","192.168.1.2","192.168.1.3"};
		PeerFactorySimulation peerFactory = new PeerFactorySimulation(d);
		int myPeerIndex = MainConfiguration.getSingleton().peerIndex;
		experiment.initPeers(myPeerIndex, 1, peerFactory);
		experiment.startPeers(myPeerIndex, 1);
		System.out.println("Bound to: "
				+ experiment.getPeers().elementAt(myPeerIndex)
						.getNetworkAddress());
	}

}
